<?php

    require ( 'init.inc.php' );
    require ( 'checkadmin.inc.php');
    require ( __COMM_PATH . 'pagecontrol.inc.php' );
    require ( __COMM_PATH . 'checkform.func.php' );
    require ( __CLASS_PATH . 'page_edit.class.php' );

    // -------------------------------------------------------
    // 接收传递过来的变量
    // -------------------------------------------------------
    $action = $_REQUEST["action"];
    $id     = addslashes($_REQUEST["id"]);
    //$classid= intval($_GET["classid"]);
    //if (!is_numeric($classid)) feedback($clang["pls_enter_news_class"]);

    // -------------------------------------------------------
    // 页面基本设置
    // -------------------------------------------------------
    $page_title   = $ptitle["ad_edit"];
    $page_type    = "edit";
    $display_page = "coupon_edit.htm";
    $table_name   = "{$tablepre}coupon";
    $condition    = "WHERE `id`='{$id}'";
    $back_page    = "coupon_list.php?sortby={$_GET['sortby']}&oexp={$_GET['oexp']}&page={$_GET['page']}&classid={$classid}&keyword={$_GET['keyword']}";

    // -------------------------------------------------------
    // 保存编辑数据
    // -------------------------------------------------------
    if ($action=="submit") {
        $couponpwd = dhtmlspecialchars(check_empty($_POST["couponpwd"],$clang[couponpwd]));
		$status = dhtmlspecialchars(check_numeric($_POST["status"],$clang[status]));
		$conponval =check_numeric($_POST["couponval"],$clang[couponval]);
        $coupontim= date ("Y-m-d H:i:s", strtotime($_POST["coupontim"]));
        $adduser = dhtmlspecialchars($_POST["adduser"]);
        $fields_arr = array(
            "couponpwd" => $couponpwd,
            "status" => $status,
            "couponval" => $conponval,
            "coupontim" => $coupontim,
            "adduser" => $adduser
        );
	     file_log($_SESSION['AdminUser'],"修改优惠券");
    }



    $tpl->assign("status", 1);
    $tpl->assign('addtime', date("Y-m-d H:i:s"));
    $tpl->assign('adduser', $_SESSION["AdminUser"]);
    // -------------------------------------------------------
    // 执行页面处理
    // -------------------------------------------------------
	//$tpl->assign("classid", $classid);
    show_page_head($page_type, $page_title);
    $pedit = new PageEdit($page_title, $back_page, $page_type);
    $pedit->SetParam($table_name, $condition);
    $pedit->UpdateData($fields_arr);
    $pedit->TplParse($display_page);
    show_page_foot();
    $db->close();
?>